package com.atguigu.day01;

import java.util.concurrent.TimeUnit;

class Phone{
    public static synchronized void sendEmail() throws Exception{
        TimeUnit.SECONDS.sleep(4);
        System.out.println("----sendEmail");
    }

    public  synchronized void Sms() throws Exception{
        System.out.println("----Sms");
    }

    public  void hello() {
        System.out.println("HelloWord");
    }
    }


public class Lock8 {
    public static void main(String[] args) throws InterruptedException {
        Phone phone = new Phone();
        Phone phone2 = new Phone();


        new Thread(() -> {
        try {
            phone.sendEmail();
        }catch (Exception e){
            e.printStackTrace();
        }
        },"线程1").start();

        Thread.sleep(10);

        new Thread(() -> {
            try {

              phone2.Sms();

            }catch (Exception e){
                e.printStackTrace();
            }
        },"线程2").start();
    }


}
